<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['namespace' => 'Auth', 'prefix' => 'auth'], function () {
    Route::post('login', 'LoginController@login');
    Route::post('logout','LoginController@logout')->middleware('auth:api');
});

Route::group(['middleware' => 'refresh'], function () {
    /**
     * 用户路由
     */
    Route::group(['namespace' => 'Account', 'prefix' => 'account'], function () {
        Route::get('profile', 'AccountController@profile');
        Route::post('profile', 'AccountController@update');
        Route::post('password', 'AccountController@modifyPassword');
        // 查询通知
        Route::get('get_notification','AccountController@get_notification');
        // 通知标为已读
        Route::get('notification_read/{notification}','AccountController@notification_read');
        // 通知删除
        Route::get('notification_deleted/{notification}','AccountController@notification_deleted');
    });
    Route::apiResource('user', 'UserController');
	/**
	 * 用于其他模型关联用户的下拉菜单数据
	 */
    Route::get('/select/users', 'UserController@getAllUsers');

    /**
     * 系统管理路由
     */
    Route::group(['namespace' => 'System', 'prefix' => 'system'], function () {
        Route::apiResource('role', 'RoleController');
        Route::get('role/{role}/permission', 'RoleController@getRolePermission');
        Route::patch('role/{role}/permission', 'RoleController@syncRolePermission');
        Route::apiResource('permission', 'PermissionController');
	    /**
	     * 通知公告
	     */
	    Route::apiResource('notification','NotificationController');
    });

    /**
     * 公司管理
     */
    Route::apiResource('company', 'CompanyController', [
    	'only' => ['index', 'update']
	]);
	/**
	 * 修改公司Logo
	 */
    Route::post('company/{company}/modifylogo', 'CompanyController@modifyLogo');

    /**
     * 门店管理
     */
    Route::apiResource('shop', 'ShopController');
	/**
	 * 关联用户至门店
	 */
    Route::post('shop/{shop}/syncmembers', 'ShopController@syncMembers');
    /**
     * 关联任务至门店
     */
    Route::post('shop/{shop}/syncTasks', 'ShopController@syncTasks');
    /**
     * 门店添加用户
     */
    Route::get('shop_add_user/{shop}/{user}','ShopController@shop_add_user');
    /**
     * 门店删除用户
     */
    Route::get('shop_delete_user/{shop}/{user}','ShopController@shop_delete_user');
    /**
     * 门店添加任务
     */
    Route::get('shop_add_task/{shop}/{task}','ShopController@shop_add_task');
    /**
     * 门店删除任务
     */
    Route::get('shop_delete_task/{shop}/{task}','ShopController@shop_delete_task');

    /**
     * 任务分类管理
     */
    Route::apiResource('category','CategoryController');
	/**
	 * 根据分类ID绑定任务到分类
	 */
    Route::post('category/{category}/attachTasks', 'CategoryController@attachTaskById');

    /**
     * 任务管理
     */
    Route::apiResource('task','TasksController');
    /**
     * 任务添加分类
     */
    Route::get('task_add_category/{task}/{category}','TasksController@task_add_category');
    /**
     * 任务删除分类
     */
    Route::get('task_delete_category/{task}/{category}','TasksController@task_delete_category');
    /**
     * Banner管理
     */
    Route::apiResource('banner','BannerController');

    /**
     * 通知管理
     */
    Route::apiResource('notification','NotificationController');


    /**
     * base64图片上传
     */
    Route::post('base64_imageUpload', 'GongGongController@base64_imageUpload');
    /**
     * 图片上传
     */
    Route::post('imageUpload', 'GongGongController@imageUpload');
    /**
     * 文件上传
     */
    Route::post('Upload', 'GongGongController@Upload');
    /**
     * 图片删除
     */
    Route::post('imageDelete', 'GongGongController@imageDelete');

    /**
     * 分析报表
     */
    /**
     * 门店维度报表
     */
    Route::post('shop_report','ReportController@shop');
    /**
     * 根据[门店id, 用户id]查询巡店记录
     */
    Route::post('shop_xun_dian_ji_lu','ReportController@shop_xun_dian_ji_lu');
    /**
     * 人员维度报表
     */
    Route::post('user_report','ReportController@user');
    /**
     * 任务维度报表
     */
    Route::post('plan_report','ReportController@plan');

    /**
     * mobile
     */
    /**
     * 根据门店id查询任务
     */
    Route::get('shop_get_task','Mobile\XunDianGuanLiController@shop_get_task');
    /**
     *  保存巡店数据
     */
    Route::post('xun_dian_data_save','Mobile\XunDianGuanLiController@xun_dian_data_save');
    /**
     * 保存用户计划
     */
    Route::apiResource('plan','PlanController');
    /**
     * 根据用户获取门店
     */
    Route::get('user_get_shop','Mobile\XunDianGuanLiController@user_get_shop');

    /**
     * 查询巡店数据
     */
    Route::get('xun_dian_list','XunDianGuanLiController@xun_dian_list');

    /**
     * 查询巡店明细
     */
    Route::get('xun_id_get_min_xi/{XunDianJiLu}','XunDianGuanLiController@xun_id_get_min_xi');

    /**
     * 巡店进度报表查询
     */
    Route::get('XunDianBaoBiao','Mobile\XunDianJingDuController@XunDianBaoBiao');

    /**
     * 巡店进度报表明细
     */
    Route::get('XunDianXiangQing','Mobile\XunDianJingDuController@XunDianXiangQing');


    /**
     * 月每天提交人数
     */
    Route::post('month_people','DashboardController@month_people');

});
